//==========================================================================//
//                                                                          //
//  SHT11 Library               Version 0.1                     March 2012  //
//                                                                          //
//  Written for the Arduino Duemilanove w/ ATmega328                        //
//                                                                          //
//  SHT11 Arduino Library                                                   //
//                                                                          //
//  Created by JFLagarde (jeanfrancoislagarde@hotmail.com)                  //
//                                                                          //
//  This file is part of OpenWS (http://code.google.com/p/openws/)          //
//                                                                          //
//==========================================================================//
//                                                                          //
//  Notes:                                                                  //
//                                                                          //
//                                                                          //
//==========================================================================//
//                                                                          //
//  Copyright 2012 Jean-Francois Lagarde (jeanfrancoislagarde@hotmail.com)  //
//  This program is distributed under the terms of                          //
//  the GNU General Public License                                          //
//                                                                          //
//  This program is free software: you can redistribute it and/or modify    //
//  it under the terms of the GNU General Public License as published by    //
//  the Free Software Foundation, either version 3 of the License, or       //
//  (at your option) any later version.                                     //
//                                                                          //
//  This program is distributed in the hope that it will be useful,         //
//  but WITHOUT ANY WARRANTY; without even the implied warranty of          //
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           //
//  GNU General Public License for more details.                            //
//                                                                          //
//  You should have received a copy of the GNU General Public License       //
//  along with this program.  If not, see <http://www.gnu.org/licenses/>.   //
//                                                                          //
//==========================================================================//

#ifndef _SHT11_H_
	#define _SHT11_H_

	#if defined(ARDUINO) && ARDUINO >= 100
		#include "Arduino.h"
	#else
		#include "WProgram.h"
	#endif

	class SHT11 {
		public:
			SHT11();
			void init();
			void init(int, int);
			void read();
			int getTemperature();
			int getHumidity();
		
		private:	
			
			int _shtClk, _shtData;
			int _ioByte, _ackBit, _dly;
			
			int _lastTemperature;
			int _lastHumidity;
			
			int readTemperature(void);
			int readHumidity(int);
			
			void softReset(void);
			void connectionReset(void);
			void start(void);
			int readData(int);
			void writeByte(void);
			void readByte(void);
			int shiftIn(void);
			void wait(void);

	};
#endif /*_SHT11_H_*/